/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import logs.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 *
 * @author Kdc
 */
public class Logs {

    private static Log logSelecionado;

    public Logs() {
    }

    public void grava() {
        try {
            FileOutputStream fo = new FileOutputStream("src/serializados/LogSelecionado.dat");
            ObjectOutputStream oo = new ObjectOutputStream(fo);
            oo.writeObject(logSelecionado);
            oo.close();
            System.out.println("Dados gravados com sucesso");
        } catch (Exception e) {
            System.err.println("Erro ao serializar " + e.getMessage());
        }
    }

    public void leitura() {
        try {
            File arq = new File("src/serializados/LogSelecionado.dat");
            FileInputStream fi = new FileInputStream(arq.getAbsolutePath());
            ObjectInputStream oi = new ObjectInputStream(fi);
            logSelecionado = (Log) oi.readObject();
            oi.close();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

}
